package cn.yuanqiao.quartz.task;

import cn.yuanqiao.archive.liyong.service.IYqdyDaService;
import cn.yuanqiao.common.utils.DateUtils;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.quartz.util.MethodDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component("dydaTask")
public class DydaTask {
    private static final Logger log = LoggerFactory.getLogger(DydaTask.class);

    @Autowired
    private IYqdyDaService yqdyDaService;

    @MethodDescription("订阅任务定时任务，arg0需要传入tenantCode")
    public void search(String tenantCode)
    {
        if(StringUtils.isNotEmpty(tenantCode)){
            Date start = new Date();
            log.info("订阅任务开始="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,start));
            yqdyDaService.search(tenantCode);
            Date end = new Date();
            log.info("订阅任务结束="+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,end));
            log.info("耗时="+(end.getTime()-start.getTime())+"毫秒");
        }else {
            log.error("TenantCode is null");
        }
    }
}
